package org.smr.ministore.micro.client;

import java.util.List;

import org.blade.utils.Pager;
import org.smr.ministore.entities.Organ;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import feign.hystrix.FallbackFactory;

@Component
public class HystrixOrganClientFactory implements FallbackFactory<FeignOrganMicroServiceClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(HystrixOrganClientFactory.class);

    @Override
    public FeignOrganMicroServiceClient create(Throwable cause) {
        HystrixOrganClientFactory.LOGGER.info("fallback; reason was: {}", cause.getMessage());

        return new OrganFeignClientWithFactory() {

            @Override
            public Organ queryById( Long id ) {
                Organ entity = new Organ();
                entity.setId(-1L);
                return entity;
            }

            @Override
            public int batchSave( List< Organ> entities){
                return 0;
            }



            public int save(Organ entity){
                return 0;
            }

            public int updateById(Organ id){
                return 0;
            }

            public int deleteById(Long id){
                 return 0;
            }

            public Pager<Organ> paginate( Organ entity, Long pageSize, Long pageNum){
                Pager<Organ> pager = new Pager<Organ>();
                return pager;
            }

        };//Return end
    }
}